//
//  TRHeadView.m
//  Weather-UI-V1
//
//  Created by tarena on 15-6-23.
//  Copyright (c) 2015年 tarena. All rights reserved.
//

#import "TRHeadView.h"
#import "TRLabelTool.h"

static CGFloat inset = 20;// 留边
static CGFloat temperatureHeight = 110;
static CGFloat hiloHeight = 40;
static CGFloat iconHeight = 30;
static CGFloat cityHeight = 30;
static CGFloat statusBarHeight = 20;
#define COLOR_WHITE [UIColor colorWithWhite:1 alpha:0.5]

@implementation TRHeadView

- (id)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {
        //字体
//        UIFont *font = [UIFont fontWithName:@"HelveticaNeue-Light" size:28];
        
        //城市

        
        CGRect cityBtnFrame = CGRectMake(0, statusBarHeight, frame.size.width, cityHeight);
        //  顶部城市名称
        self.cityBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        self.cityBtn.frame = cityBtnFrame;
        self.cityBtn.titleLabel.text = @"";
        self.cityBtn.titleLabel.textColor = COLOR_WHITE;
        //self.cityBtn.backgroundColor = [UIColor redColor];
        [self addSubview:self.cityBtn];
        
        CGRect cityFrame = CGRectMake(0, statusBarHeight, frame.size.width, cityHeight);
        //  顶部城市名称
        self.cityLabel = [TRLabelTool labelWithFrame:cityFrame];
        self.cityLabel.text = @"";
        self.cityLabel.textColor = COLOR_WHITE;
        
        [self addSubview:self.cityLabel];
        
        //温度
        CGRect temperatureFrame = CGRectMake(inset, frame.size.height - (temperatureHeight + hiloHeight), frame.size.width - 2 * inset, temperatureHeight);
        // 创建Label，并加入headerView
        self.tempratureLabel = [TRLabelTool labelWithFrame:temperatureFrame];
        //self.tempratureLabel.backgroundColor = [UIColor redColor];
        self.tempratureLabel.font = [UIFont fontWithName:@"HelveticaNeue-UltraLight" size:120];
        self.tempratureLabel.textAlignment = NSTextAlignmentLeft;
        self.tempratureLabel.text = @"23°";
        self.tempratureLabel.textColor = COLOR_WHITE;
        [self addSubview:self.tempratureLabel];
        
        
        
        //最高/低温度
        CGRect hiloFrame = CGRectMake(inset, frame.size.height - hiloHeight, frame.size.width - 2*inset, hiloHeight);
        self.hiloLabel = [TRLabelTool labelWithFrame:hiloFrame];
        //self.hiloLabel.backgroundColor = [UIColor blackColor];
        self.hiloLabel.text = @"23° / 12°";
        self.hiloLabel.textColor = COLOR_WHITE;
        self.hiloLabel.textAlignment = NSTextAlignmentLeft;
        //for test
       // self.hiloLabel.backgroundColor = [UIColor blueColor];
        
        [self addSubview:self.hiloLabel];
        
        
        //图标
        CGRect iconFrame = CGRectMake(inset, temperatureFrame.origin.y - iconHeight, iconHeight, iconHeight);
        // 天气图标
        UIImageView *iconView = [[UIImageView alloc] initWithFrame:iconFrame];
        iconView.contentMode = UIViewContentModeScaleAspectFit;
        //iconView.backgroundColor = [UIColor clearColor];
        iconView.image = [UIImage imageNamed:@"weather-clear.png"];
        [self addSubview:iconView];
        
        
        
        
        CGRect conditionFrame = iconFrame;
        conditionFrame.size.width = frame.size.width - 2 * inset - iconHeight - 10;
        conditionFrame.origin.x = iconFrame.origin.x + iconHeight + 10;
        //  天气情况描述
        self.conditionLabel = [TRLabelTool labelWithFrame:conditionFrame];
        self.conditionLabel.text = @"Clear";
        self.conditionLabel.textColor = COLOR_WHITE;
        self.conditionLabel.textAlignment = NSTextAlignmentLeft;
        
        //for test
        //self.conditionLabel.backgroundColor = [UIColor greenColor];
        
        [self addSubview:self.conditionLabel];
    }
    
    return self;
    
    
}



@end
